import logging

from pylons import request, response, session, tmpl_context as c
from pylons.controllers.util import abort, redirect_to

from datetime import date, datetime

from horseanalysis.lib.base import render
from horseanalysis.controllers.application import ApplicationController
from horseanalysis.model.race import Race
from horseanalysis.model.win_place import WinPlace
from horseanalysis.model.quinella import Quinella
from horseanalysis.model.quinella_place import QuinellaPlace
from horseanalysis.model.race_batch import RaceBatch

log = logging.getLogger(__name__)

class DashboardController(ApplicationController):

  def index(self):
    if c.current_race:
      c.current_batches = RaceBatch.get_race_batches(c.current_race)
      c.current_batch = RaceBatch.get_latest_batch(c.current_race)
      c.win_place = WinPlace.get_odds(c.current_batch)
      c.quinella = Quinella.get_odds(c.current_batch)
      c.quinella_place = QuinellaPlace.get_odds(c.current_batch)
    
    return render('/dashboard/index.html')